import { MyVue } from 'src/wl/my_vue';
import Vue from 'vue';
import { Component, Emit, Prop, Provide, Watch } from 'vue-property-decorator'
import { AccManageConst } from "src/consts/acc_manage_const";
import { OrganizationConst } from "src/consts/organization_const";
@Component({})
export default class AccPanel extends MyVue {
    name: string = 'AccPanel';
    formData: any;
    footerFlag: boolean = true;
    beforeCreate(): void {
    }

    initData(that?: any): void {
        that.formData = WLStore().state.accManageShow;
    }

    mounted(): void {
    }

    editAcc(): void {
        this.$refs.accForm.validate((valid: Boolean) => {
            if (valid) {
                var sendData: any = this.formData
                delete sendData.create_time
                delete sendData.dept_id
                delete sendData.dept_name
                delete sendData.entity_id
                delete sendData.feature_cod
                delete sendData.ip
                delete sendData.login_time
                delete sendData.role_id
                delete sendData.role_name
                delete sendData.update_time
                delete sendData.type

                if (isNoEmpty(sendData.role_list)) {
                    for (let i = 0; i < sendData.role_list.length; i++) {
                        for (let k in sendData.role_list[i]) {
                            if (k != "id") {
                                delete sendData.role_list[i][k]
                            }
                        }
                    }
                    WLDispatch(AccManageConst.DispatchEdit, sendData);
                }


            } else {
                WLMessage("必填字段为空,无法编辑账号", "warning")
                return false;
            }
        })
    }


    openOrg(): void {
        WLCommit(OrganizationConst.CommitType, "acc")
        let sendData: any = {}
        sendData["curr_page"] = 1
        sendData["page_size"] = 15
        sendData.level = 0
        WLDispatch(OrganizationConst.GetOrgTreeData, sendData);
    }
}